﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using System.Data.SqlClient;

public partial class ShowNewList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        newList.ItemCommand +=
             new DataGridCommandEventHandler(this.showNewInfo);
        getNewList();
    }

    protected void getNewList()
    {
        String coursesql = "select title, text, author, Replace(CONVERT(varchar, date, 111),'/','-') AS date from new order by ID desc";
        DataSet newDataSet = DataBase.Query(coursesql);
        newList.DataSource = newDataSet.Tables[0].DefaultView;
        newList.DataBind();
    }

    protected void showNewInfo(Object sender, DataGridCommandEventArgs e)
    {
        switch (((LinkButton)e.CommandSource).CommandName)
        {
            case "showNew":
                newInfo(sender, e);
                break;
            default:
                break;

        }

    }
    protected void newInfo(object sender, DataGridCommandEventArgs e)
    {
        LinkButton selectButton = (LinkButton)e.CommandSource;
        String newTitle = selectButton.Text;
        Session.Add("newTitle", newTitle);
        Server.Transfer("ShowNew.aspx");
    }

}
